{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" team="{:url('/admin/productcate')}" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">搜索名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="keyword" value="{$Request.get.keyword}" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">一级分类</label>
                    <div class="layui-input-block">
                        <select name="cate_id" style="width:100%">
                            <option value="">--请选择状态--</option>
                            {volist name="cate" id="vo"}
                            <option value="{$vo['id']}" {if condition="$Request.get.cate_id eq $vo['id']"}selected{/if}>{$vo['title']}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" href="{:url('/admin/productcate_add')}">添加商品分类</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table" style="text-align:center">
                <thead>
                <tr>
                    <th>分类名称</th>
                    <th>排序值</th>
                    <th>添加时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                    {volist name="list" id="vo"}
                        <tr>
                            <td>{$vo['title']}&nbsp;&nbsp;{if condition="$vo['pid'] gt 0"}<img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;">{/if}</td>
                            <td>{$vo['sort']}</td>                            
                            <td>{$vo['addtime']|date="Y-m-d H:i:s"}</td>
                            <td>
                                <a style="text-decoration:none" title="编辑" href="{:url('/admin/productcate_edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-radius layui-btn-default layui-btn-xs">
                                    <i class="layui-icon layui-icon-edit"></i>编辑
                                </a>
                                <a style="text-decoration:none" title="删除" onClick="del({$vo.id},'3')" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">删除</a>
                                
                            </td>
                        </tr>
                        {volist name="vo['cate']" id="vv" length="leg" key="key" }
                            <tr>
                                <td>{if condition="$key eq count($vo['cate'])"}└─{else /}├─{/if} {$vv['title']}&nbsp;&nbsp;{if condition="$vv['pid'] gt 0"}<img src="{PHP} echo imageUrl($vv['imgurl']){/php}" style="width:40px;height:40px;">{/if}</td>
                                <td>{$vv['sort']}</td>
                                
                                <td>{$vv['addtime']|date="Y-m-d H:i:s"}</td>
                                <td>
                                    <a style="text-decoration:none" title="编辑" href="{:url('/admin/productcate_edit',['id'=>$vv['id']])}" class="layui-btn layui-btn-radius layui-btn-default layui-btn-xs">
                                        <i class="layui-icon layui-icon-edit"></i>编辑
                                    </a>
                                    <a style="text-decoration:none" title="删除" onClick="del({$vv.id},'3')" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">删除</a>
                                    
                                </td>
                            </tr>
                        {/volist}
                    {/volist}
                
                        {if condition="empty($list)"}
                            <tr><td colspan='10' style="text-align:center;">暂时没有数据！</td></tr>
                        {/if}
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default" style="margin-left:40%">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['table'], function(){

    });
    //上下架
    function del(id,stu){
        layer.confirm('确认要执行当前操作吗？',function(){
            var url = "{:url('/admin/productcate_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'stu':stu},function(data){
                if(data.status == 1){
                    layer.msg(data.msg,{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1500},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }



</script>
</body>
</html>


